package com.hntest.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hntest.dao.SystemDictionaryItemDao;
import com.hntest.entity.Page;
import com.hntest.entity.SystemDictionary;
import com.hntest.entity.SystemDictionaryItem;
import com.hntest.service.SystemDictionaryItemService;
/**
 * 数据字典明细的业务类
 * @author ZHOU
 *
 */
@Service("dictionaryItemSetvice")
public class DictionaryItemService implements SystemDictionaryItemService{

	@Autowired
	private SystemDictionaryItemDao dictionaryItemDao;
	
	//查询数据字典明细的总记录数
	@Override
	public int getCount() {
		int n = dictionaryItemDao.getCount();
		return n;
	}

	//分页查询数据字典明细数据
	@Override
	public List<SystemDictionaryItem> getListByPage(Page page, SystemDictionaryItem condition) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("pageStart",((page.getCurrPage()-1)*page.getPageSize()+1));
        map.put("pageEnd",(page.getCurrPage()*page.getPageSize()));
        map.put("condition", condition);
        List<SystemDictionaryItem> list = dictionaryItemDao.getListByPage(map);
		return list;
	}

	//删除数据字典明细
	@Override
	public int deleteItem(int id) {
		SystemDictionaryItem dictionaryitem = new SystemDictionaryItem();
		dictionaryitem.setItemId(id);
		int n = dictionaryItemDao.deleItem(dictionaryitem);
		return n;
	}

	//新增数据字典明细
	@Override
	public int insertItem(String title, int parentid) {
		SystemDictionaryItem item = new SystemDictionaryItem();
		SystemDictionary d = new SystemDictionary();
		d.setDictionaryId(parentid);
		item.setParent(d);
		item.setItemTitle(title);
		int n = dictionaryItemDao.insertItem(item);
		return n;
	}

	//条件查询总记录数
	@Override
	public int getConditionCount(SystemDictionaryItem condition) {
		return dictionaryItemDao.getConditionCount(condition);
	}

	
	

}
